<template>
    <div>
        <el-form :model="formData" label-position="right" label-width="80px">
            <el-form-item label="项目总金额（万）:">
                <el-input-number v-model="formData.allPrice" :precision="2" clearable></el-input-number>
            </el-form-item>

            <el-form-item label="申请授信金额:">
                <el-input-number v-model="formData.applyPrice" :precision="2" clearable></el-input-number>
            </el-form-item>

            <el-form-item label="施工企业授权委托书:">
                <el-input v-model="formData.authClientBook" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="开户行:">
                <el-input v-model="formData.bankAddress" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="项目结算账户名:">
                <el-input v-model="formData.bankName" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="项目结算账号:">
                <el-input v-model="formData.bankNumber" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="中标通知书:">
                <el-input v-model="formData.bidFile" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="中标合同:">
                <el-input v-model="formData.bidOntract" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="项目经理，技术负责人和施工负责人签字样式确认及承诺书:">
                <el-input v-model="formData.commitment" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="施工许可证:">
                <el-input v-model="formData.conCer" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="施工单位:">
                <el-input v-model="formData.conUnit" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="信用报告:">
                <el-input v-model="formData.creditReport" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="控股股东或实控连带担保承诺函:">
                <el-input v-model="formData.holderCommitLetter" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="当前状态，0为申请:"><el-input v-model.number="formData.nowStatus" clearable placeholder="请输入"></el-input>
            </el-form-item>

            <el-form-item label="发包单位:">
                <el-input v-model="formData.outUnit" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="项目唯一指定结算账户确认书及承诺书:">
                <el-input v-model="formData.payCommitLetter" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="规划许可证:">
                <el-input v-model="formData.planCer" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="项目地点:">
                <el-input v-model="formData.proAddress" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="项目名称:">
                <el-input v-model="formData.proName" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="项目工期:">
                <el-input v-model="formData.proTime" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="安全生成许可证:">
                <el-input v-model="formData.saveCer" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="投标文件:">
                <el-input v-model="formData.tenderFile" clearable placeholder="请输入" ></el-input>
            </el-form-item>

            <el-form-item label="会员ID:"><el-input v-model.number="formData.userId" clearable placeholder="请输入"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button @click="save" type="primary">保存</el-button>
                <el-button @click="back" type="primary">返回</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import {
        createUserProject,
        updateUserProject,
        findUserProject
    } from "@/api/userProject";  //  此处请自行替换地址
    import infoList from "@/mixins/infoList";
    export default {
        name: "UserProject",
        mixins: [infoList],
        data() {
            return {
                type: "",formData: {
                    allPrice:0,
                    applyPrice:0,
                    authClientBook:"",
                    bankAddress:"",
                    bankName:"",
                    bankNumber:"",
                    bidFile:"",
                    bidOntract:"",
                    commitment:"",
                    conCer:"",
                    conUnit:"",
                    creditReport:"",
                    holderCommitLetter:"",
                    nowStatus:0,
                    outUnit:"",
                    payCommitLetter:"",
                    planCer:"",
                    proAddress:"",
                    proName:"",
                    proTime:"",
                    saveCer:"",
                    tenderFile:"",
                    userId:0,

                }
            };
        },
        methods: {
            async save() {
                let res;
                switch (this.type) {
                    case "create":
                        res = await createUserProject(this.formData);
                        break;
                    case "update":
                        res = await updateUserProject(this.formData);
                        break;
                    default:
                        res = await createUserProject(this.formData);
                        break;
                }
                if (res.code == 0) {
                    this.$message({
                        type:"success",
                        message:"创建/更改成功"
                    })
                }
            },
            back(){
                this.$router.go(-1)
            }
        },
        async created() {
            // 建议通过url传参获取目标数据ID 调用 find方法进行查询数据操作 从而决定本页面是create还是update 以下为id作为url参数示例
            if(this.$route.query.id){
                const res = await findUserProject({ ID: this.$route.query.id })
                if(res.code == 0){
                    this.formData = res.data.reuserProject
                    this.type = "update"
                }
            }else{
                this.type = "create"
            }

        }
    };
</script>

<style>
</style>